package top.amot.forceview.model


abstract class AbstractNodeModel {
    var nodeList: MutableList<AbstractNode> = mutableListOf()
    var linkList: MutableList<AbstractLink<AbstractNode,AbstractNode>> = mutableListOf()

    constructor() {}

    fun addNode(node: AbstractNode) {
        nodeList.add(node)
    }

    fun addNodes(nodes:List<AbstractNode>){
        nodeList.addAll(nodes)
    }

    fun addLink(link: AbstractLink<AbstractNode,AbstractNode>) {
        linkList.add(link)
    }

    fun addLinks(links:List<AbstractLink<AbstractNode,AbstractNode>>){
        linkList.addAll(links)
    }

    fun addLink(scr: Node, desc: Node) {
        if (!nodeList.contains(scr)) nodeList.add(scr)
        if (!nodeList.contains(desc)) nodeList.add(desc)
        addLink(Link(scr, desc, ""))
    }
}